# 使用 with...as 配合open函数以rb 方式，打开路径为"/Users/yequ/音频.wav"的音频
with open("/Users/yequ/音频.wav","rb") as fp:
    # 使用read()函数读取音频赋值给wavsample
    wavsample = fp.read()

# 使用from...impirt从aip中导入AipSpeech
from aip import AipSpeech

# 存储访问密钥信息，包括客户端ID、API接口验证序号和API接口密钥
APP_ID = "10252021"
API_KEY = "ZHe7788sh11GEjIAdEKeY"
SECRET_KEY = "JMMzHe7788BUSH1ZhEnM1YUEhh"


# 传入密钥创建AipSpeech客户端，并将结果存储在client中 
client = AipSpeech(APP_ID, API_KEY, SECRET_KEY)

# 调用短语音识别接口把结果赋值给rejson变量
rejson = client.asr(wavsample,"wav",16000,{"dev_pid": 1737})

# 获取语音识别结果
# 从返回结果中提取出参数result中的唯一值并赋值给变量msg
msg = rejson["result"][0]

#使用from...import...从MyQR模块中导入myqr
from MyQR import myqr

# 从myqr中调用run()函数
# 添加参数words，参数值为msg语音识别的结果
# 添加参数save_name，参数值为"yequ.png"
# 添加参数picture,参数值为"/Users/yequ/voice.png"
# 将二维码设置为彩色
# 边长设置为10
myqr.run(words = msg,
         save_name = "yequ.png",
         picture = "/Users/yequ/voice.png",
         colorized = True,
         version = 10)